import { checkToken } from '@/utils'
import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      redirect: '/mapHome',
      component: HomeView,
      children: [
        {
          path: 'mapHome',
          name: 'mapHome',
          component: () => import('@/views/Perimeter/index.vue'),
          redirect: '/mapHome/map',
          children: [
            {
              path: 'map',
              name: 'map',
              component: () => import('@/views/Perimeter/Map/index.vue')
            },
            {
              path: 'config',
              name: 'config',
              component: () => import('@/views/Perimeter/Config/index'),
              children: [
                {
                  path: 'camera',
                  name: 'camera',
                  component: () => import('@/views/Perimeter/Config/components/Camera')
                },
                {
                  path: 'device',
                  name: 'device',
                  component: () => import('@/views/Perimeter/Config/components/Device')
                },
                {
                  path: 'history',
                  name: 'history',
                  component: () => import('@/views/Perimeter/History/components/StatisticAnalysis')
                }
              ]
            }
          ]
        },
        {
          path: 'inspection',
          name: 'inspection',
          redirect: '/inspection/control-home',
          meta: {
            title: '安保机器人'
          },
          children: [
            {
              path: 'control-home',
              name: 'control-home',
              component: () => import('@/views/Perimeter/InspectionControlHome.vue'),
              meta: {
                title: '操控端'
              }
            },
            {
              path: 'robot-manage',
              name: 'robot-manage',
              component: () => import('@/views/Perimeter/InspectionRobotManage.vue'),
              meta: {
                title: '机器人管理'
              }
            },
            {
              path: 'resource-manage',
              name: 'resource-manage',
              component: () =>
                import('@/views/Perimeter/inspection/ResourceManage/ResourceManage.vue'),
              meta: {
                title: '资源管理'
              }
            },
            {
              path: 'map-setting',
              name: 'map-setting',
              component: () => import('@/views/Perimeter/inspection/MapSettingIndex.vue'),
              meta: {
                title: '地图设置'
              }
            },
            {
              path: 'inspection-control',
              name: 'inspection-control',
              component: () => import('@/views/Perimeter/inspection/InspectionControl.vue'),
              meta: {
                title: '操控端详情',
                hidden: true
              }
            },
            {
              path: 'voice-intercom',
              name: 'voice-intercom',
              component: () => import('@/views/Perimeter/inspection/VoiceIntercom.vue'),
              meta: { title: '语音对讲', hidden: true }
            }
          ]
        }
      ]
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/LoginPage.vue'),
      meta: {
        title: '登录'
      }
    }

    // {
    //   path: '/role',
    //   name: 'role',
    //   component: () => import('@/views/Permission/RoleView.vue'),
    //   meta: {
    //     title: '角色列表'
    //   }
    // },
    // {
    //   path: '/user',
    //   name: 'user',
    //   component: () => import('@/views/Permission/UserView.vue'),
    //   meta: {
    //     title: '用户列表'
    //   }
    // }
  ]
})

checkToken(router)

export default router
